<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
        <p id="text">点击复制后在右边textarea CTRL+V看一下</p>
        <input type="text" id="inputText" value="测试文本"/>
        <input type="button" id="btn" value="复制"/>
        <textarea rows="4"></textarea>
    <script>
        var btn = document.getElementById('btn');
        btn.addEventListener('click', function(){
        let select=window.getSelection()
        var inputText = document.getElementById('inputText');
        let ranges=select.deleteFromDocument()
        console.log(select)
        var currentFocus = document.activeElement;
        inputText.focus();
        // inputText.setSelectionRange(0, inputText.value.length);
        document.execCommand('fontSize', true,'7');
        currentFocus.focus();
        console.log(currentFocus)
    });
    </script>
</body>
</html>